<template>
	<view class="tab">
		<view class="tab_item" :class="index == current ?'action':''" v-for="(item, index) in list" :key="index"
			@click="change(index)">
			{{item.name}}
		</view>
	</view>
</template>

<script setup>
	import {
		ref
	} from "vue"

	let list = ref([{
		name: "全部"
	}, {
		name: "客厅"
	}, {
		name: "卧室"
	}, {
		name: "厨房"
	}])

	let current = ref(0);
	const change = (i) => {
		current.value = i
	}
</script>

<style lang="scss">
	.tab {
		display: flex;
		align-items: center;

		.action {
			font-weight: bold;
			position: relative;
			font-size: 38rpx;

			&::before {
				content: "";
				display: block;
				height: 8rpx;
				border-radius: 30rpx;
				width: calc(100% - 40rpx);
				transform: translate(-50%);
				position: absolute;
				bottom: 0;
				left: 50%;
				background: var(--color);
			}
		}

		&_item {
			// margin: 20rpx;
			padding: 20rpx;
			font-size: 32rpx;
			margin: 10rpx;
		}
	}
</style>